from pao_python.pao import log
from service.ianalysis_statistics_data import IAnalysisStatistics
from pao_python.pao.service.security.security_utility import PermissionUtility
from app.permission import Permission
#工业标识-统计分析服务接口
def register(jsonrpc, db_addr, db_port,db_name,session):
    analysis_statistics = IAnalysisStatistics(db_addr,db_port,db_name)
    Permission_utility = PermissionUtility(db_addr,db_port,db_name,session)

    #标识总数统计
    @jsonrpc.method('IAnalysisStatisticsService.line_data')
    def line_data_service(handle_type):
        def pass_permission():
            res = analysis_statistics.cal_line_data(handle_type)
            return res
        return Permission_utility.is_peimission_pass(pass_permission,Permission.StatisticalAnalysis_Select)
    
    #解析总数统计
    @jsonrpc.method('IAnalysisStatisticsService.total_analysis_bar')
    def total_analysis_bar_service():
        def pass_permission():        
            res = analysis_statistics.cal_total_analysis_bar()    
            return res
        return Permission_utility.is_peimission_pass(pass_permission,Permission.StatisticalAnalysis_Select)


    #解析排行总数统计
    @jsonrpc.method('IAnalysisStatisticsService.AnalysStatistics')
    def analysStatistics_service(handle_type):
        def pass_permission():        
            res = analysis_statistics.cal_analysStatistics(handle_type)
            return res
        return Permission_utility.is_peimission_pass(pass_permission,Permission.StatisticalAnalysis_Select)
    
    
